import instance from '../utils/http'
// discuss.js
// 根据用户id查询不同状态的订单信息
export const reqGetShopList = (userid) => {
    // 增加非空判断，避免传 undefined
    if (!userid) {
      return Promise.reject(new Error('userid 不能为空'));
    }
    return instance.get(`/ordercake/selectOrdercake/?userid=${userid}`);
  };
// 用户确认收货
export const confirmGoodsMenthod = (orderid) => {
    // 增加非空判断，避免传 undefined
    if (!orderid) {
      return Promise.reject(new Error('orderid 不能为空'));
    }
    return instance.post(`/ordercake/confirmGoods/?orderid=${orderid}`);
  };
  // 用户删除订单
export const deleteGoodsMenthod = (orderid) => {
    // 增加非空判断，避免传 undefined
    if (!orderid) {
      return Promise.reject(new Error('orderid 不能为空'));
    }
    return instance.post(`/ordercake/deleteGoods/?orderid=${orderid}`);
  };
  // 申请退款
export const reqApplyRefund = (orderid,userreason) => {
    // 增加非空判断，避免传 undefined
    if (!orderid) {
      return Promise.reject(new Error('orderid 不能为空'));
    }
    if (!userreason) {
        return Promise.reject(new Error('userreason 不能为空'));
      }
    return instance.post(`/ordercake/applyrefund?orderid=${orderid}&userreason=${userreason}`);
  };
  // 根据userid查询退款订单
  export const reqGetApplyRefundList = (userid) => {
    // 增加非空判断，避免传 undefined
    if (!userid) {
      return Promise.reject(new Error('userid 不能为空'));
    }
    return instance.get(`/ordercake/selectapplyfundFront/?userid=${userid}`);
  };
//模糊查询蛋糕——搜索蛋糕
export const searchGetList=(searchval)=>{
  return instance.post('/cake/selectCakeList',searchval);
}
